<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------


use think\Db;
function get_user_info()
{

}

function get_user_name($user_id) {
    $name = Db::table('user')
        ->where(['dd_user_id' => $user_id])
        ->value('name');
    return $name ? $name : '未知';
}

function addLog($msg,  $type = 1, $id = 0, $user = 'null') {
    Db::table('log')->insert([
        'type' => $type,
        'table_id' => $id,
        'content' => $msg,
        'add_user' => $user,
        'add_time' => date('Y-m-d H:i:s')
    ]);
}

/**
 * @auther zlq
 * @create_time 2020/6/9 18:05
 * @description 获取配置
 * @param $name
 * @return array|mixed
 */
function getDicList($name) {
    $list = config('dic.'.$name);
    if (!empty($list)){
        $temp = [];
        foreach ($list as $key => $item) {
            $temp[] = [
                'data_id' => $key,
                'data_name' => $item
            ];
        }
        return $temp;
    } else {
        return [];
    }
}

/**
 * @auther zlq
 * @create_time 2020/7/17 9:18
 * @description 字体根据状态添加颜色
 * @param $word 文字
 * @param $status 状态
 * @return string
 */
function get_status_color($word, $status)
{
    switch ($status) {
        case 1:
            $data = "<font color='#83ba20'>" . $word . "</font>";
            break;
        case 2:
            $data = "<font color='#f4b301'>" . $word . "</font>";
            break;
        case 3:
            $data = "<font color='#0fd1c5'>" . $word . "</font>";
            break;
        case 4:
            $data = "<font color='#1fadff'>" . $word . "</font>";
            break;
        case 5:
            $data = "<font color='#01c03f'>" . $word . "</font>";
            break;
        case 6:
            $data = "<font color='#e1b700'>" . $word . "</font>";
            break;
        case 7:
            $data = "<font color='#569ce2'>" . $word . "</font>";
            break;
        case 8:
            $data = "<font color='#00aaaa'>" . $word . "</font>";
            break;
        case 9:
            $data = "<font color='#ff7e23'>" . $word . "</font>";
            break;
        case 10:
            $data = "<font color='#2773eb'>" . $word . "</font>";
            break;
        case 11:
            $data = "<font color='#018287'>" . $word . "</font>";
            break;
        case 12:
            $data = "<font color='#e56c19'>" . $word . "</font>";
            break;
        case 13:
            $data = "<font color='#1c58b8'>" . $word . "</font>";
            break;
        case 14:
            $data = "<font color='#15992b'>" . $word . "</font>";
            break;
        case 15:
            $data = "<font color='#4617b5'>" . $word . "</font>";
            break;
        case 99:
            $data = "<font color='#e1341e'>" . $word . "</font>";
            break;
        default:
            $data = $word;
            break;
    }

    return $data;
}